<!--  -->
<template>
  <div></div>
</template>

<script>
import * as WindowType from '@/config/windowtype.js'
import VueFunctions from '@/core/VueFunctions.js'
import { mapGetters } from 'vuex'
export default {
  computed: {
    ...mapGetters([
      'currentSite',
      'alllanguage'
    ])
  },
  created () {
    VueFunctions.method(WindowType.CHANGE_CURRENT_DESIGN_SITE, (site) => {
      this.$confirm('是否要切换到 ' + this.showLanguageByLanguageId(site.languageId) + ' 站点进行编辑?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.$load('/site/change', { siteId: site.id }).then((response) => {
          if (response && parseInt(response) === 1) {
            window.location.href = window.location.href
          }
        })
      }).catch(() => {
      })
    })
  },
  data () {
    return {
    }
  },
  methods: {
    showLanguageByLanguageId (id) {
      let item = this.alllanguage.find(ele => {
        return parseInt(ele.id) === parseInt(id)
      })
      if (!item) {
        return '未知：' + id
      }
      return item.name
    }
  }
}

</script>
